package lego

import (
	"github.com/valyala/fasthttp"
	"net/http"
)

/*
 * 统一处理options相关逻辑的中间件
 ————————————————————————
*/


func middlewareOptions(next fasthttp.RequestHandler) fasthttp.RequestHandler {
	return fasthttp.RequestHandler(func(ctx *fasthttp.RequestCtx) {
	    if ctx.IsOptions() {
			//ctxExt := RequestCtxExtent{ctx}
			ctx.Response.SetStatusCode(http.StatusOK)
			//ctx.Response.Header.Set("Content-type", "application/json")
			//ctx.Write([]byte("  ddd"))
			//ctxExt.ResponseWithStateCode200(100, fmt.Sprintf("recover from panic: %s", "2"))
	    	return
		}
		next(ctx)
	})
}
